package com.zjapl.web.dao.impl;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import com.zjapl.web.action.vo.Team;
import com.zjapl.web.dao.TeamDao;

/** 
 * @author 作者:方武斌    E-mail: fangwb@zjapl.com
 * @version 创建时间：2013-1-15 上午9:13:57 
 * 类说明 
 */
public class TeamDaoImpl implements TeamDao {
	private static SqlMapClient sqlMapClient = null;

	// 读取配置文件
	static {
		try {
			Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
			sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public boolean addTeam(Team team){
		// TODO Auto-generated method stub	
		try{
			if(sqlMapClient.insert("AddTeam", team)!=null){  //判断得到的对象是否为空，不为空返回true
				
				 return true;
			 }			 
		  }catch(SQLException e){
			  e.printStackTrace();
		  }
		   return false;
	}

	public boolean deleteTeam(int team_id){
		try{
			sqlMapClient.delete("DeleteTeam", team_id);
			return true;
		}catch(SQLException e){
			  e.printStackTrace();
		  }
		   return false;
	}
}
